Skip to content

Components: add "Naming conventions" section - #63714

Merged
ciampo merged 13 commits into
trunkfrom
docs/components-contributing-guidelines-compound-naming
Aug 8, 2024
Merged

ciampo merged 13 commits into
trunkfrom
docs/components-contributing-guidelines-compound-naming

Conversation

@ciampo

@ciampo ciampo commented Jul 18, 2024 •

Copy link
Copy Markdown
Contributor

What?

Closes #63242

Tweak the contributing guidelines, updating a few out of date parts and adding a new "Naming Conventions" section based on the conversation happening in #63242

Why?

As we introduce more compound components in the package, we need a recommended naming conventions for both monolithic and compound components going forward.

@ciampo ciampo self-assigned this Jul 18, 2024
@ciampo ciampo added the [Type] Developer Documentation Documentation for developers label Jul 18, 2024
@ciampo
ciampo requested a review from a team July 18, 2024 15:30
@ciampo

ciampo commented Jul 18, 2024

Copy link
Copy Markdown
Contributor Author

@WordPress/gutenberg-components I took an initial stab at updating the contributing guidelines.

Also cc @diegohaz in case you have any feedback.

@ciampo
ciampo marked this pull request as ready for review July 18, 2024 15:31
@ciampo
ciampo requested a review from ajitbohra as a code owner July 18, 2024 15:31
@github-actions

github-actions Bot commented Jul 18, 2024 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org>
Co-authored-by: diegohaz <hazdiego@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: noisysocks <noisysocks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo changed the title Components: update contributing guidelines and add "Naming conventions" section Components: add "Naming conventions" section Jul 18, 2024
- [README example](#README-example)
- [Folder structure](#folder-structure)
- [Component versioning](#component-versioning)
- [Introducing new components](#introducing-new-components)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My IDE insists on auto-formatting this file. I've put all the auto-formatting changes in one single commit, but if you think they're too distracting / they don't belong to this PR I'm happy to remove and potentially apply them in a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

It's also easier to review the PR with white-spacing disabled:

Screenshot 2024-08-01 at 14 05 08

Comment on lines +98 to +104
When adding new components or new props to existing components, it's recommended to create a [private version](/packages/private-apis/README.md)) of the component until the changes are stable enough to be exposed as part of the public API.

### Learn more

- [How to preserve backward compatibility for a React Component](/docs/contributors/code/backward-compatibility.md#how-to-preserve-backward-compatibility-for-a-react-component)
- [Experimental and Unstable APIs](/docs/contributors/code/coding-guidelines.md#experimental-and-unstable-apis)
- [Deprecating styles](#deprecating-styles)
- [How to preserve backward compatibility for a React Component](/docs/contributors/code/backward-compatibility.md#how-to-preserve-backward-compatibility-for-a-react-component)
- [Experimental and Unstable APIs](/docs/contributors/code/coding-guidelines.md#legacy-experimental-apis-plugin-only-apis-and-private-apis)
- [Deprecating styles](#deprecating-styles)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this section to reflect the new "private APIs" policy

Comment thread packages/components/CONTRIBUTING.md Resolved

@tyxla tyxla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more or less looking good, but still has some debatable elements (the Component.Root dot notation mostly) that still needs a stronger consensus in the #63242 discussion at this time.

Comment thread packages/components/CONTRIBUTING.md Resolved
Comment thread packages/components/CONTRIBUTING.md Resolved
Comment thread packages/components/CONTRIBUTING.md Resolved
Comment thread packages/components/CONTRIBUTING.md Resolved
Comment thread packages/components/CONTRIBUTING.md Resolved

@DaniGuardiola DaniGuardiola left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, though it seems like we're switching to an "overloaded" API?

@mirka

mirka commented Jul 30, 2024 •

Copy link
Copy Markdown
Member

@DaniGuardiola and I were discussing some potential TypeScript problems with overloading when forwardRef() is involved.

It's a bit finicky where you need to place your JSDocs and .displayNames, but I can confirm that this approach with Object.assign is working as expected for IntelliSense and the Storybook docgen.

@ciampo
ciampo force-pushed the docs/components-contributing-guidelines-compound-naming branch from b26f91e to bdfe95c Compare July 31, 2024 15:05
@ciampo
ciampo requested review from DaniGuardiola, mirka and tyxla July 31, 2024 15:33
@ciampo

ciampo commented Jul 31, 2024

Copy link
Copy Markdown
Contributor Author

I've updated the PR suggesting the "overloaded" naming convention and refreshing the code examples.

Could y'all take a new look?

(as I'm going to be AFK for a week, feel free to push updates and/or merge in case in my absence)

@tyxla tyxla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great 👍

I've left some minor things mostly, I'll let @mirka and @DaniGuardiola take a look and share their feedback before we ship it.

Comment thread packages/components/CONTRIBUTING.md Resolved
Comment thread packages/components/CONTRIBUTING.md Outdated
const Context = createContext();

/** The top-level component's JSDoc. */
export const Component = Object.assign(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a good opportunity to explain the purpose behind using Object.assign() here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and it might be useful to state what exactly we need to look for:

  • When consuming the component/subcomponent, the JSDocs must appear correctly in IntelliSense.
  • The main component JSDoc must appear in the Storybook docs page.
  • The component/subcomponent prop types must appear correctly in the Storybook props table.

@ciampo ciampo Aug 8, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of paragraphs explaining requirements and related recommended best practices: 432635b

This way the only comments in the code are related to the JSDocs

Comment thread packages/components/CONTRIBUTING.md Resolved
Comment thread packages/components/CONTRIBUTING.md Resolved
- [README example](#README-example)
- [Folder structure](#folder-structure)
- [Component versioning](#component-versioning)
- [Introducing new components](#introducing-new-components)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

It's also easier to review the PR with white-spacing disabled:

Screenshot 2024-08-01 at 14 05 08

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update! I had a few notes on top of @tyxla's review, but otherwise this looks great 👍

Comment thread packages/components/CONTRIBUTING.md Resolved
@ciampo
ciampo force-pushed the docs/components-contributing-guidelines-compound-naming branch from 737dbb6 to 432635b Compare August 8, 2024 07:34
@ciampo

ciampo commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

All feedback should be addressed

@ciampo
ciampo requested review from mirka and tyxla August 8, 2024 07:37

@tyxla tyxla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go from my perspective. Thanks @ciampo 🚀

Comment thread packages/components/CONTRIBUTING.md Resolved
@ciampo
ciampo enabled auto-merge (squash) August 8, 2024 09:31
@github-actions

github-actions Bot commented Aug 8, 2024

Copy link
Copy Markdown

Flaky tests detected in cb6485c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10299502863
📝 Reported issues:

@ciampo
ciampo merged commit 236250e into trunk Aug 8, 2024
@ciampo
ciampo deleted the docs/components-contributing-guidelines-compound-naming branch August 8, 2024 09:59
@github-actions github-actions Bot added this to the Gutenberg 19.1 milestone Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@wordpress/components: agree on a naming convention for compound (sub) components

5 participants